package org.example.osproject01;

import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import org.example.osproject01.Object.Job;

import static org.example.osproject01.Object.PublicResource.preInputQueue;

public class addJobController {

    public Button ok;
    public TextField name;
    public TextField priority;
    public TextField runTime;
    public TextField needSpace;
    public TextField needTape;
    public TextField submitTime;

    public void onOk(MouseEvent mouseEvent) {
        if(name.getText().equals("") || priority.getText().equals("") || needSpace.getText().equals("") || runTime.getText().equals("") || needTape.getText().equals("")) {
            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("Error Dialog");
            alert.setHeaderText("信息不完整");
            alert.setContentText("请重新输入作业信息！");
            alert.showAndWait();
        }else{
            preInputQueue.add(new Job(name.getText(),runTime.getText(),needSpace.getText(),needTape.getText(),priority.getText(),submitTime.getText()));
        }
    }

}
